# Copyright (C) Kumo inc. and its affiliates.
# Author: Jeff.li lijippy@163.com
# All rights reserved.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https:#www.gnu.org/licenses/>.
#

add_executable(pollux_hdfs_file_test HdfsFileSystemTest.cpp HdfsMiniCluster.cpp
                                    HdfsUtilTest.cpp)

add_test(pollux_hdfs_file_test pollux_hdfs_file_test)
target_link_libraries(
  pollux_hdfs_file_test
  pollux_file
  pollux_hdfs
  pollux_core
  pollux_exec_test_lib
  pollux_hive_connector
  pollux_dwio_common_exception
  pollux_exec
  GTest::gtest
  GTest::gtest_main
  GTest::gmock)

target_compile_options(pollux_hdfs_file_test
                       PRIVATE -Wno-deprecated-declarations)

add_executable(pollux_hdfs_insert_test InsertIntoHdfsTest.cpp
                                      HdfsMiniCluster.cpp HdfsUtilTest.cpp)

add_test(pollux_hdfs_insert_test pollux_hdfs_insert_test)

target_link_libraries(
  pollux_hdfs_insert_test
  pollux_exec_test_lib
  pollux_exec
  GTest::gtest
  GTest::gtest_main
  GTest::gmock)

target_compile_options(pollux_hdfs_insert_test
                       PRIVATE -Wno-deprecated-declarations)

# pollux_hdfs_insert_test and pollux_hdfs_file_test two tests can't run in
# parallel due to the port conflict in Hadoop NameNode and DataNode. The
# namenode port conflict can be resolved using the -nnport configuration in
# hadoop-mapreduce-client-jobclient-3.3.0-tests.jar. However the data node port
# cannot be configured. Therefore, we need to make sure that
# pollux_hdfs_file_test runs only after pollux_hdfs_insert_test has finished.
set_tests_properties(pollux_hdfs_insert_test PROPERTIES DEPENDS
                                                       pollux_hdfs_file_test)
